// pages/detail/detail.js
const http = require("../../models/http")
Page({
  data: {
    value:""
  },

  onLoad: function (options) {
    console.log(options.id);
    let id = options.id;
    http({
      url:`http://192.168.4.18:3000/playlist/detail?id=${id}`,
      success:res=>{
        this.setData({
          value:res.data.playlist
        })
      }
    })
  },
  onClick(event){
    this.data.value.tracks.forEach(res=>{
      if(res.id==event.currentTarget.dataset.id){
        res.state = !res.state
      }else{
        res.state = false
      }
    })
    this.setData({
      value:this.data.value
    })
    // console.log(this.data.value);
  }
})